using System;
using System.Collections;
using System.Collections.Generic;
using QFramework;
using UnityEngine;

[RequireComponent(typeof(SpriteRenderer))]
[RequireComponent(typeof(PoolObj))]
[RequireComponent(typeof(Collider2D))]
public class ItemObject : MonoBehaviour
{
    [SerializeField]private ItemData itemData;
    private SpriteRenderer spriteRenderer;

    public ItemData GetItemData()
    {
        return itemData;
    }
    
    private void Awake()
    {
        spriteRenderer = GetComponent<SpriteRenderer>();
    }
    void Start()
    {
        spriteRenderer.sprite = itemData.itemIcon;
    }
    void Update()
    {
        
    }

    private void OnTriggerEnter2D(Collider2D other)
    {
        InventoryManager.Instance.AddItem(itemData);
        gameObject.DestroySelfGracefully();
        //PoolMgr.Instance.PushObj(gameObject);
    }
}
